When A view goes back it is removed from the parent view controller and this call happens
yourViewController.willMove(toParentViewController: nil)
so maybe you can override the call and
override func willMove(toParentViewController: UIViewController) {
if toParentViewController == nil {
// take action
}
super.willMove(toParentViewController: toParentViewController)
}